<template>
  <div>
    <el-table
      :data="tabData"
      :height="$store.state.app.tableHeight"
      border
      style="width: 100%; font-size:12px"
    >
      <el-table-column
        label="授权品牌名"
        align="center"
      >
        <template slot-scope="scope">
          <span>{{ scope.row.brand_content.brand_name }}</span>
        </template>
      </el-table-column>
      <el-table-column
        prop="product_code_num"
        label="产品代码"
        align="center"
      />
      <el-table-column
        prop="brand_product_name"
        label="产品名称"
        align="center"
      />
      <el-table-column
        prop="gg"
        label="规格"
        align="center"
      />
      <el-table-column
        prop="pany"
        label="单位"
        align="center"
      />
      <el-table-column
        prop="price"
        label="产品统一售价"
        align="center"
      />
      <el-table-column label="操作" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="mini" @click="check(scope.row)">查看</el-button>
          <el-button type="text" size="mini" @click="handleCheck(scope.row)">修改</el-button>
          <del-comfirn :title="`是否确认删除名称为“ ${scope.row.brand_product_name} ”的商品？`" button-text="删除" @onConfirm="delProductInfo(scope.row)" />
        </template>
      </el-table-column>
    </el-table>
    <product-info ref="resetComp" operation-type="2" @reloadFun="reloadFun" />
  </div>
</template>

<script>
import delComfirn from '@/components/DelConfirm'
import { operationBrandProduct } from '@/api/brand'
import productInfo from './product-info'
export default {
  components: {
    delComfirn,
    productInfo
  },
  props: {
    tabData: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
    }
  },
  methods: {
    delProductInfo(row) {
      console.log(row)
      const data = {
        type: 3,
        id: row.id
      }
      operationBrandProduct(data).then(res => {
        console.log(res)
        if (res.code === 200) {
          this.$message.success('删除成功！')
          this.$emit('reloadFun')
        }
      })
    },
    handleCheck(row) {
      this.$refs.resetComp.dialogFormVisible = true
      this.$refs.resetComp.form = JSON.parse(JSON.stringify(row))
      this.$refs.resetComp.isDisable = false
    },
    reloadFun() {
      this.$emit('reloadFun')
    },
    check(row) {
      this.$refs.resetComp.dialogFormVisible = true
      this.$refs.resetComp.form = JSON.parse(JSON.stringify(row))
      this.$refs.resetComp.isDisable = true
    }
  }
}
</script>

<style lang="sass" scoped>

</style>
